These tutorial materials will give students in “Quantifying History” a very basic understanding and feel for R and RStudio. This will allow us to hit the ground running in the course, though we will go over some of these basics in the course as well and you can certainly come with questions. The tutorials are broken up into units that should take between 10-20 minutes each and all told I’d guess these will keep you busy for 3-4 hours or so.
Install R and Rstudio. Follow steps 1 and 2 at https://swirlstats.com/students.html.
Install swirl and three tutorials. To do this, go to the same
page (https://swirlstats.com/students.html), install swirl
(which is step 3 on the webpage). Once you’ve installed swirl [i.e.,
what you did by typing: install.packages("swirl") in R],
install the tutorials by typing
swirl::install_course("R Programming")
and press enter. This installs the first tutorial. Now install the other two by typing (and hitting enter after each line):
swirl::install_course("Regular Expressions")
swirl::install_course("Exploratory Data Analysis")
[The above shaded windows indicate what to enter into the R console in the lower left-hand window of RStudio]
Now you can open swirl by entering:
library("swirl")
swirl()
(You only have to type the first line (library("swirl"))
once per R session – i.e., if you exit swirl but don’t close RStudio,
you can enter swirl again by simply typing: swirl(). If you
close RStudio (or restart R within RStudio), you’ll need to repeat the
first line as well (which loads the package).
You will have to install some packages as you work through the swirl tutorials. Swirl should be able to handle this for you. If you have troubles and need to install them by hand, see step 5 below.
[For those who prefer textbooks there is an excellent one online at https://r4ds.had.co.nz/index.html. Chapters 1-20 cover roughly the same material as the swirl tutorials but in much greater depth. That will take a lot longer than a couple of hours to go through but if you’re interested and want to do more, that’s where I’d start.]
install.packages("NAME_OF_PACKAGE")
## So, for instance, to install the first package listed above you’ll type:
install.packages("tidyverse")
Do get in touch if you have difficulties with any of this!
2022.